package org.ziegler.log.analysis.resultHandler;

import org.apache.commons.collections4.MultiValuedMap;
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
import org.apache.commons.lang3.StringUtils;

import org.ziegler.log.analysis.LogCore;
import org.ziegler.log.analysis.core.SplitColumn;

public class AllResultHandler implements ResultHandler {

    /** 记录所有日志 */
    private final MultiValuedMap<String, SplitColumn> allSplitError = new ArrayListValuedHashMap<>();

    @Override
    public void addResult(SplitColumn splitColumn) {
        if (StringUtils.isNotBlank(splitColumn.getKey())){
            // 保存所有Error
            allSplitError.put(splitColumn.getKey(), splitColumn);
        }
    }

    @Override
    public void output() {
        LogCore.info("ErrorKey size = " + allSplitError.keySet().size());
        allSplitError.keySet().forEach(key -> {
            // 所有key
            LogCore.log(key + " - " + allSplitError.get(key).size());
        });
    }

}
